package com.dragon.pear.modules.trade.service.assistants.converters;

import java.sql.Timestamp;
import com.dragon.common.base.utils.ConvertUtil;
import com.dragon.common.base.utils.DbUtil;
import com.dragon.common.spring.annotations.DataConverter;
import com.dragon.common.spring.business.base.BaseConverter;
import com.dragon.utils.TimeUtil;
import com.dragon.pear.modules.trade.domain.entity.TradeGoodsImageEntity;
import com.dragon.pear.modules.trade.web.model.params.create.TradeGoodsImageCreateParam;
import com.dragon.pear.modules.trade.web.model.params.update.TradeGoodsImageUpdateParam;
import com.dragon.pear.modules.trade.web.model.results.TradeGoodsImageResult;

/**
 * @author Chris Chan
 * Create on 2025-09-30 22:06
 * Use for: 商品图片关联 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class TradeGoodsImageConverter implements BaseConverter<
        TradeGoodsImageEntity,
        TradeGoodsImageCreateParam,
        TradeGoodsImageUpdateParam,
        TradeGoodsImageResult> {
    @Override
    public TradeGoodsImageEntity fromParam(TradeGoodsImageCreateParam param) {
        TradeGoodsImageEntity entity = new TradeGoodsImageEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public TradeGoodsImageEntity fromUpdateParam(TradeGoodsImageUpdateParam param) {
        TradeGoodsImageEntity entity = ConvertUtil.convert(param, TradeGoodsImageEntity.class);
        return entity;
    }

    @Override
    public TradeGoodsImageResult toResult(TradeGoodsImageEntity entity) {
        TradeGoodsImageResult result = ConvertUtil.convert(entity,TradeGoodsImageResult.class);
        return result;
    }
}